home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_apache2.idb / usr / freeware / apache2 / include / apr_xlate.h.z / apr_xlate.h
C/C++ Source or Header  |  2002-07-08  |  8KB  |  192 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  */
  54.  
  55. #ifndef APR_XLATE_H
  56. #define APR_XLATE_H
  57.  
  58. #include "apr.h"
  59. #include "apr_pools.h"
  60. #include "apr_errno.h"
  61.  
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif /* __cplusplus */
  65.  
  66. /**
  67.  * @file apr_xlate.h
  68.  * @brief APR I18N translation library
  69.  */
  70.  
  71. /**
  72.  * @defgroup APR_I18N I18N translation library
  73.  * @ingroup APR
  74.  * @{
  75.  */
  76.  
  77. /**
  78.  * APR_HAS_XLATE determines whether or not useful implementations of 
  79.  * apr_xlate_open() et al are provided. 
  80.  *
  81.  * If APR_HAS_XLATE is zero, apr_xlate_open() et al will all return 
  82.  * APR_ENOTIMPL at run-time.
  83.  */
  84.  
  85. typedef struct apr_xlate_t            apr_xlate_t;
  86.  
  87. /**
  88.  * Set up for converting text from one charset to another.
  89.  * @param convset The handle to be filled in by this function
  90.  * @param topage The name of the target charset
  91.  * @param frompage The name of the source charset
  92.  * @param pool The pool to use
  93.  * @remark
  94.  *  Specify APR_DEFAULT_CHARSET for one of the charset
  95.  *  names to indicate the charset of the source code at
  96.  *  compile time.  This is useful if there are literal
  97.  *  strings in the source code which must be translated
  98.  *  according to the charset of the source code.
  99.  *  APR_DEFAULT_CHARSET is not useful if the source code
  100.  *  of the caller was not encoded in the same charset as
  101.  *  APR at compile time.
  102.  *
  103.  * @remark
  104.  *  Specify APR_LOCALE_CHARSET for one of the charset
  105.  *  names to indicate the charset of the current locale.
  106.  * </PRE>
  107.  */
  108. APR_DECLARE(apr_status_t) apr_xlate_open(apr_xlate_t **convset, 
  109.                                          const char *topage, 
  110.                                          const char *frompage, 
  111.                                          apr_pool_t *pool);
  112.  
  113. /** 
  114.  * This is to indicate the charset of the sourcecode at compile time
  115.  * names to indicate the charset of the source code at
  116.  * compile time.  This is useful if there are literal
  117.  * strings in the source code which must be translated
  118.  * according to the charset of the source code.
  119.  */
  120. #define APR_DEFAULT_CHARSET (const char *)0
  121. /**
  122.  * To indicate charset names of the current locale 
  123.  */
  124. #define APR_LOCALE_CHARSET (const char *)1
  125.  
  126. /**
  127.  * Find out whether or not the specified conversion is single-byte-only.
  128.  * @param convset The handle allocated by apr_xlate_open, specifying the 
  129.  *                parameters of conversion
  130.  * @param onoff Output: whether or not the conversion is single-byte-only
  131.  */
  132. APR_DECLARE(apr_status_t) apr_xlate_sb_get(apr_xlate_t *convset, int *onoff);
  133.  
  134. /** @deprecated @see apr_xlate_sb_get */
  135. APR_DECLARE(apr_status_t) apr_xlate_get_sb(apr_xlate_t *convset, int *onoff);
  136.  
  137. /**
  138.  * Convert a buffer of text from one codepage to another.
  139.  * @param convset The handle allocated by apr_xlate_open, specifying 
  140.  *                the parameters of conversion
  141.  * @param inbuf The address of the source buffer
  142.  * @param inbytes_left Input: the amount of input data to be translated
  143.  *                     Output: the amount of input data not yet translated    
  144.  * @param outbuf The address of the destination buffer
  145.  * @param outbytes_left Input: the size of the output buffer
  146.  *                      Output: the amount of the output buffer not yet used
  147.  */
  148. APR_DECLARE(apr_status_t) apr_xlate_conv_buffer(apr_xlate_t *convset, 
  149.                                                 const char *inbuf, 
  150.                                                 apr_size_t *inbytes_left, 
  151.                                                 char *outbuf,
  152.                                                 apr_size_t *outbytes_left);
  153.  
  154. /* @see apr_file_io.h the comment in apr_file_io.h about this hack */
  155. #ifdef APR_NOT_DONE_YET
  156. /**
  157.  * The purpose of apr_xlate_conv_char is to translate one character
  158.  * at a time.  This needs to be written carefully so that it works
  159.  * with double-byte character sets. 
  160.  * @param convset The handle allocated by apr_xlate_open, specifying the
  161.  *                parameters of conversion
  162.  * @param inchar The character to convert
  163.  * @param outchar The converted character
  164.  */
  165. APR_DECLARE(apr_status_t) apr_xlate_conv_char(apr_xlate_t *convset, 
  166.                                               char inchar, char outchar);
  167. #endif
  168.  
  169. /**
  170.  * Convert a single-byte character from one charset to another.
  171.  * @param convset The handle allocated by apr_xlate_open, specifying the 
  172.  *                parameters of conversion
  173.  * @param inchar The single-byte character to convert.
  174.  * @warning This only works when converting between single-byte character sets.
  175.  *          -1 will be returned if the conversion can't be performed.
  176.  */
  177. APR_DECLARE(apr_int32_t) apr_xlate_conv_byte(apr_xlate_t *convset, 
  178.                                              unsigned char inchar);
  179.  
  180. /**
  181.  * Close a codepage translation handle.
  182.  * @param convset The codepage translation handle to close
  183.  */
  184. APR_DECLARE(apr_status_t) apr_xlate_close(apr_xlate_t *convset);
  185.  
  186. /** @} */
  187. #ifdef __cplusplus
  188. }
  189. #endif
  190.  
  191. #endif  /* ! APR_XLATE_H */
  192.